#ifndef N_SCENEBUILDER_H
#define N_SCENEBUILDER_H

#include "util/nstack.h"

//------------------------------------------------------------------------------

class nSceneNode;

class nSceneBuilder
{
public:
    
    nSceneBuilder();
    
    bool BeginNode( nSceneNode* );

    void EndNode();

protected:

    virtual bool DoBeginNode( nSceneNode* ) = 0;

    nStack<nSceneNode*> nodeStack;
};

//------------------------------------------------------------------------------

inline nSceneBuilder::nSceneBuilder()
{
    //
}

//------------------------------------------------------------------------------

inline bool nSceneBuilder::BeginNode( nSceneNode* sceneNode )
{
    n_assert( sceneNode );
    if ( this->DoBeginNode( sceneNode ) )
    {
        this->nodeStack.Push( sceneNode );
        return true;
    }

    return false;
}

//------------------------------------------------------------------------------

inline void nSceneBuilder::EndNode()
{
    n_assert( !this->nodeStack.IsEmpty() );
    this->nodeStack.Pop();
}

#endif /*N_SCENEBUILDER_H*/
